﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GestureLib;
using System.Windows.Forms;

namespace GesturePad
{
    class SpecialEditorTextAction : IGestureAction
    {
        public enum SpecialAction
        { 
            Space,
            BackSpace
        }

        public SpecialAction Action { get; set; }
        public TextBoxBase TextBox { get; set; }

        #region IGestureAction Members

        public void Execute()
        {
            switch (Action)
            {
                case SpecialAction.Space:
                    TextBox.Text = TextBox.Text.Insert(TextBox.SelectionStart, " ");
                    break;
                case SpecialAction.BackSpace:
                    if (TextBox.Text.Length > 0 && TextBox.SelectionStart > 0)
                    {
                        TextBox.Text = TextBox.Text.Remove(TextBox.SelectionStart - 1, 1);
                    }
                    break;

                default:
                    throw new NotImplementedException("This SpecialAction is not implemented yet!");
            }

            TextBox.SelectionStart = TextBox.Text.Length;
        }

        #endregion

        #region INamed Members

        public string Name { get; set; }

        #endregion
    }
}
